package com.web.controller;


import com.web.dto.UserInfoDTO;
import com.web.service.UserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

/**
 * @author yangguanzan
 * @date 9/8/21
 * @description
 */

@Controller
@RequestMapping("/userInfo")
public class UserInfoController {

    @Autowired
    UserInfoService userInfoService;

    @RequestMapping("/findById")
    public String findById(ModelMap model,Long id) {
        UserInfoDTO userInfo=userInfoService.findById(id);
        model.addAttribute("userInfo",userInfo);
        //forward:/redirect:
        return "userInfoDetail";
    }

    @RequestMapping("/page")
    public String page(@RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
        @RequestParam(name = "pageSize",defaultValue = "3") Integer pageSize, Model model) {
        model.addAttribute("data",userInfoService.findByPage(pageNum,pageSize));
        //forward:/redirect:
        return "userInfoList";
    }
}